package com.mulanweb.utils;

import com.jfinal.kit.HashKit;
import com.mulanweb.db.common.Configure;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;

/**
 * Created by Administrator on 2016/10/9.
 */
public class WxSignUtil {

    public static String createGetPrepayIdSign(SortedMap<Object, Object> para) {
        StringBuffer sb = new StringBuffer();
        Set es = para.entrySet();
        Iterator it = es.iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();
            String k = (String) entry.getKey();
            Object v = entry.getValue();
            if (null != v && !"".equals(v)
                    && !"sign".equals(k) && !"key".equals(k)) {
                sb.append(k + "=" + v + "&");
            }
        }
        sb.append("key=" + Configure.getKey());
        String sign = HashKit.md5(sb.toString()).toUpperCase();
        return sign;
    }
}
